package ynu.edu.achitecturework.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import ynu.edu.achitecturework.common.entity.LogicEntity;

import javax.persistence.*;

@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Table(name = "device")
public class Device extends LogicEntity {

    @Column(nullable = false)
    private String name;

    @Column(nullable = false, unique = true)
    private String serialNumber;

    @Column(nullable = false)
    private String deviceType;

    private String unit;

    private String monitorUrl;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "greenhouse_id", nullable = false)
    @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
    private Greenhouse greenhouse;
}